Linux运维平台工具:pstree、ps、top、htop、free、vmstat、dstat、kill、killall、ipcalc |
您所在的位置:网站首页 › ps top › Linux运维平台工具:pstree、ps、top、htop、free、vmstat、dstat、kill、killall、ipcalc |
1、pstree命令 查看进程树,centos7下统一由systemd进行管理 [root@ELK-chaofeng systemd]# pstree systemd─┬─AliYunDun───18*[{AliYunDun}] ├─AliYunDunUpdate───3*[{AliYunDunUpdate}] ├─CmsGoAgent.linu───9*[{CmsGoAgent.linu}] ├─2*[agetty] ├─aliyun-service───2*[{aliyun-service}] ├─atd ├─crond ├─dbus-daemon ├─dhclient ├─httpd───httpd───101*[{httpd}] ├─mysqld_safe───mysqld───28*[{mysqld}] ├─ntpd ├─php-fpm───2*[php-fpm] ├─polkitd───5*[{polkitd}] ├─rsyslogd───2*[{rsyslogd}] ├─sshd─┬─sshd───bash │ └─sshd───bash───pstree ├─staragentd─┬─staragent-core───40*[{staragent-core}] │ └─staragent-ppf───11*[{staragent-ppf}] ├─systemd-journal ├─systemd-logind ├─systemd-udevd └─tuned───4*[{tuned}]2、ps命令详解 ps命令有BSD风格和UNIX风格,BSD风格中,选项参数后面是不加“-”的,而UNIX风格中,选项要加上“-”,使用不同的风格,选项参数的意义是不一样的,并且大多数情况下我们使用BSD风格比较多,我们来看一下。 1)显示进程的PID,进程对应的命令,CPU利用率等信息 [root@ELK-chaofeng tmp]# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.1 43144 3604 ? Ss Feb02 0:07 /usr/lib/systemd/systemd --switched-root --system --deserialize 21 root 2 0.0 0.0 0 0 ? S Feb02 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S Feb02 0:13 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S< Feb02 0:00 [kworker/0:0H] root 7 0.0 0.0 0 0 ? S Feb02 0:00 [migration/0] root 8 0.0 0.0 0 0 ? S Feb02 0:00 [rcu_bh] root 9 0.0 0.0 0 0 ? R Feb02 0:55 [rcu_sched] root 10 0.0 0.0 0 0 ? S Feb02 0:02 [watchdog/0] root 12 0.0 0.0 0 0 ? S Feb02 0:00 [kdevtmpfs] root 13 0.0 0.0 0 0 ? S< Feb02 0:00 [netns] root 14 0.0 0.0 0 0 ? S Feb02 0:00 [khungtaskd] root 15 0.0 0.0 0 0 ? S< Feb02 0:00 [writeback] root 16 0.0 0.0 0 0 ? S< Feb02 0:00 [kintegrityd] root 17 0.0 0.0 0 0 ? S< Feb02 0:00 [bioset] root 18 0.0 0.0 0 0 ? S< Feb02 0:00 [kblockd] root 19 0.0 0.0 0 0 ? S< Feb02 0:00 [md] root 25 0.0 0.0 0 0 ? S Feb02 0:00 [kswapd0] root 26 0.0 0.0 0 0 ? SN Feb02 0:00 [ksmd]选项: a:列出与终端有关的所有process u:列出进程对应的用户,即进程的发起者是谁。 x:与选项a连用,列出系统内所有的进程。 对输出的信息进行解释。 USER:进程的发起者。 PID:此进程的PID号。 %CPU:此进程在当前时刻占用的CPU百分比。即CPU利用率 %MEM:此进程在当前时刻占用的内存百分比。即内存利用率 VSZ:此进程使用的虚拟内存集大小,。注意这并不是swap分区,两者是有区别的。 RSS:此进程占用的固定内存大小。我们把这里面的进程称为常驻内存集。常驻内存集里面的进程是不能放在swap分区里面运行的。 TTY:进程在哪个终端运行 STAT:进程此时的运行状态。 START:进程是在哪一时刻运行的。 TIME:进程实际使用CPU的时间。 COMMAND:进程对应的命令。 2)进程的状态STAT都有什么? R:running,表示此进程正在运行。 S:可中断睡眠。 D:不可中断睡眠。通常是指IO阻塞的进程。 T:停止运行。此时进程不可被调度,只能手动来进行启动。 Z:僵尸态, 孤魂野鬼,找不到归宿,父进程不来收尸或者父进程已经挂了。 不过我们看到的进程后面还有带有其他字母或字符,表示什么意思呢? +:前台进程,占据着某终端。 s:session leader l:(小写字母l)多线程进程 /dev/null; [ $? -eq 0 ] && echo "This is the correct ip address" || echo "This is not the correct ip address" This is the correct ip address [root@master01 ~]# ipcalc -c 192.774.241.6 &>/dev/null; [ $? -eq 0 ] && echo "This is the correct ip address" || echo "This is not the correct ip address" This is not the correct ip address |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |